<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BAQResource
 *
 * @author ID59C
 */
class BAQResource {

    const Key_Resource_Id = 'service_resource_id';

    //put your code here
    public $id;
    public $name;
    public $description;
    public $serviceId;
    public $maxQueueNumber;
    public $mediaId;
    public $data = array();

    /**
     * 
     * @param type $data
     * @return \BAQResource
     */
    public static function find($data = array()) {
        $resource = NULL;
        $serviceResourceId = isset($data['service_resource_id']) ? $data['service_resource_id'] : NULL;

        if ($serviceResourceId != NULL) {
            $mServiceResource = BMServiceQueueLineResource::model()->findByPk($serviceResourceId);
            $mResource = BMAppOnlineQueueServiceResource::model()->findByPk($mServiceResource->service_resource_id);
            $resource = new BAQResource();
            $resource->id = $mResource->_id;
            $resource->name = $mResource->name;
            $resource->description = $mResource->description;
            $resource->serviceId = $mResource->service_id;
            $resource->mediaId = $mResource->service_media_id;
            $resource->data = $mResource->data;
            //          $resource->queueLineId = $mServiceResource->service_queueline_id;
            $mServiceResourceMaxQueueNo = BMServiceQueueLineResourceMax::model()->findByAttributes(array('service_queueline_resource_id' => $serviceResourceId));
            if ($mServiceResourceMaxQueueNo != NULL)
                $resource->maxQueueNumber = $mServiceResourceMaxQueueNo->maxqueuenumber;
        }

        return $resource;
    }

}

?>
